package com.extension.company.presenter.home;

import com.extension.company.Constant;
import com.extension.company.model.entity.MessageBean;
import com.extension.company.common.http.RetrofitHelper;
import com.extension.company.common.mvp.BasePresenter;
import com.extension.company.contract.MessCenterListContract;
import com.extension.company.model.api.RetrofitUrlApi;
import com.extension.company.model.home.MessCenterListMode;

import io.reactivex.Observer;
import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.disposables.Disposable;
import io.reactivex.schedulers.Schedulers;

/**
 * 消息中心列表
 */
public class MessCenterListPresenter extends BasePresenter<MessCenterListContract.Model, MessCenterListContract.View> {
	RetrofitUrlApi retrofitUrlApi = RetrofitHelper.getRetrofit().create(RetrofitUrlApi.class);

	@Override
	public MessCenterListContract.Model createModel() {
		return new MessCenterListMode();
	}

	@Override
	protected void onViewDestroy() {

	}

	public void getData() {

	}

	/**
	 * 获取消息的列表
	 */
	public void messageList() {

		retrofitUrlApi.MessageList(Constant.SIGN)
				.observeOn(AndroidSchedulers.mainThread())
				.subscribeOn(Schedulers.io())
				.subscribe(new Observer<MessageBean>() {
					@Override
					public void onSubscribe(Disposable d) {

					}

					@Override
					public void onNext(MessageBean messageBean) {
						if (200 == messageBean.getCode()) {
							messageBean.getData();
						}
					}

					@Override
					public void onError(Throwable e) {

					}

					@Override
					public void onComplete() {

					}
				});

	}
}
